package cn.sc.summer.auth.service.afterlogin;

import cn.sc.summer.feign.client.SysFeignClient;
import cn.sc.summer.auth.service.afterlogin.base.BaseAfterUserLogin;
import cn.sc.summer.token.enums.LoginTypeEnum;
import cn.sc.summer.token.po.AuthorityX;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Set;

/**
 * 类名：登录成功后进行的后置操作
 *
 * @author a-xin
 * @date 2024/7/12 15:41
 */
@Slf4j
@Service
public class LoginImpl extends BaseAfterUserLogin {

    private static final long serialVersionUID = -2656243441486904036L;

    @Resource
    private SysFeignClient sysFeignClient;

    /**
     * 登录成功后进行的后置操作
     *
     * @param userId 用户ID
     */
    @Override
    public Set<AuthorityX> cacheAndGetUserAuthority(String userId) {
        return sysFeignClient.getUserAuth(userId, getSupports()).getData();
    }

    /**
     * Determine the types of data sources supported by this class
     *
     * @return Supported types
     */
    @Override
    public String supports() {
        return LoginTypeEnum.WEB.getSlogan();
    }

}
